//
//  LBRViewController.h
//  LBReact
//
//  Created by WuShiHai on 19/5/24.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <React/RCTRootView.h>
#import "LBBridge.h"

UIKIT_EXTERN NSString *const LBRChangeStatusBarStyleNotification;
UIKIT_EXTERN NSString *const LBJavaScriptWillStartLoadingModuleNotification;
UIKIT_EXTERN NSString *const LBJavaScriptDidLoadingModuleNotification;

typedef NS_ENUM(NSInteger, LBReactPageType) {
    LBReactPageTypeDefault = 0, //默认类型
    LBReactPageTypeCore = 1, //核心页面，体验&稳定性高
    LBReactPageTypeActivity = 2, //活动页面，时效性高
};

@interface LBRViewController : UIViewController

/**
 当前页面使用的bridge
 */
@property (nonatomic, weak, readwrite) LBBridge *bridge;

/**
 根视图
 */
@property (nonatomic, strong, readonly) RCTRootView *rootView;

/**
 页面类型，页面更新加载使用
 */
@property (nonatomic, assign, readonly) LBReactPageType *pageType;

/**
 页面id
 */
@property (nonatomic, strong, readonly) NSString *moduleId;

/**
 加载的模块路径
 */
@property (nonatomic, strong, readonly) NSString *componentName;

/**
 额外用户信息
 */
@property (nonatomic, strong, readonly) NSDictionary *userInfo;

/**
 初始化方法

 @param URLString 传入的链接，controller中不解析，只读
 @param module 模块名称
 @param userInfo 额外用户信息
    {
        @"rt": LBReactPageType,
    }
 @return 控制器
 */
- (instancetype)initWithURL:(NSString *)URLString
                  component:(NSString *)component
                   userInfo:(NSDictionary *)userInfo;

/**
 渲染加载script

 @param module 模块名称
 @param userInfo 额外用户信息
 */
- (void)render:(NSString *)component
      userInfo:(NSDictionary *)userInfo;

/**
 加载多包下的组件

 @param component 路径
 */
- (void)renderInMultiMode:(NSString *)component;

/**
 渲染组件
 */
- (void)loadComponent;

/**
 判断组件注册在self.bridge 中

 @param component 组件路径
 @return YES或NO
 */
- (BOOL)isRegisterComponent:(NSString *)component;

@end
